
#页面类：登录页面

from selenium.webdriver.common.by import By

from utils.page_base import PageBase

class PageLogin(PageBase):
    pathUrl="/simple/login"
    loc_zanhao=By.NAME,"login_info"
    loc_pwd=By.NAME,"password"
    loc_loginButton=By.CSS_SELECTOR,"input.input_submit"
    loc_errorTipDiv=By.CSS_SELECTOR,"div.prompt"

    def __init__(self,driver,base_url):
        PageBase.__init__(self,driver,base_url)


    #打开当前页面
    def openUrl(self):
        self.open(PageLogin.pathUrl)

    #输入账号
    def input_zanhao(self,zanhao):
        self.input(loc=PageLogin.loc_zanhao,data=zanhao)

    #输入密码
    def input_pwd(self, pwd):
        self.input(loc=PageLogin.loc_pwd, data=pwd)

    #点击登录按钮
    def click_loginButton(self):
        self.click(loc=PageLogin.loc_loginButton)


    #判断错误错误提示div标签是否出现
    def isExistsErrorTipDiv(self):
        return self.isExists(loc=PageLogin.loc_errorTipDiv)

    #获取密码框的class属性的值
    def getPwdClassAttr(self):#"input_text    valid-text  invalid-text"
        return self.getEleAttr(loc=PageLogin.loc_pwd,attrName="class")

    # 获取账号框的class属性的值
    def getZanhaoClassAttr(self):  # "input_text    valid-text  invalid-text"
        return self.getEleAttr(loc=PageLogin.loc_zanhao, attrName="class")
